package com.mall.redis;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hyt
 * @date 2021/11/04
 */
@RestController
@Slf4j
@RequestMapping("/redis")
public class RedisController {
    @Autowired
    private RedisService redisService;

    @RequestMapping("/set")
    public String set(){
        redisService.set("redis","1");
        return "ok";
    }

    @RequestMapping("/get")
    public String get(){
        Object obj=redisService.get("redis");
        if(!StrUtil.isEmptyIfStr(obj)){
            return obj.toString();
        }
        return "no";
    }

}
